Skip to content

Fix clock/calendar not respecting system locale (day/month names) - #8085

Closed
ivanlegranbizarro wants to merge 3 commits into
omacom:quattrofrom
ivanlegranbizarro:fix/clock-panel-locale
Closed

ivanlegranbizarro wants to merge 3 commits into
omacom:quattrofrom
ivanlegranbizarro:fix/clock-panel-locale

Conversation

@ivanlegranbizarro

Copy link
Copy Markdown

Bar clock and calendar popup always show English weekday/month names, even with LANG set to a non-English locale (e.g. es_ES.UTF-8).

Root cause: BarWidget.qml uses Qt.formatDateTime(date, format) and Panel.qml uses Qt.formatDate(date, format). Neither QML global accepts a locale argument, so both fall back to the C locale for token expansion (dddd, MMMM) regardless of the user's system locale.

Fix: use date.toLocaleString(Qt.locale(), format) / date.toLocaleDateString(Qt.locale(), format) instead, which do accept an explicit locale.

Tested manually with LANG=es_ES.UTF-8 — bar clock and calendar popup now show localized weekday/month names.

BarWidget.qml used Qt.formatDateTime() and Panel.qml used Qt.formatDate(),
neither of which accept a locale argument in QML — both silently fall back
to the C locale for token expansion (dddd, MMMM), so the bar clock and
calendar popup always show English day/month names regardless of the
system's LANG/LC_TIME. Using date.toLocaleDateString()/toLocaleString()
with an explicit Qt.locale() fixes this.
Copilot AI balanced review requested due to automatic review settings August 24, 2026 18:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Localizes clock and calendar date names using the system Qt locale.

Changes:

  • Uses locale-aware formatting for the bar clock.
  • Localizes calendar hero and month labels.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
shell/plugins/panels/clock/Panel.qml Localizes calendar date labels.
shell/plugins/panels/clock/BarWidget.qml Localizes bar clock formatting.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread shell/plugins/panels/clock/Panel.qml Resolved
Comment thread shell/plugins/panels/clock/Panel.qml Resolved
- test/shell.d/clock-test.sh still asserted the old Qt.formatDate() call
  for the calendar hero date; updated to assert the new locale-aware
  toLocaleDateString() call instead.
- Added a regression test for BarWidget.qml's toLocaleString(Qt.locale(), ...)
  call, so the widget's locale fix can't silently regress either.
- Panel.qml's month header used toUpperCase(), which is locale-insensitive
  and mishandles languages with special casing rules (e.g. Turkish dotted
  capital İ). Switched to toLocaleUpperCase().

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

shell/plugins/panels/clock/Panel.qml:315

  • The popup still formats its weekday headings through the hard-coded Qt.locale("en_US") (labelLocale at lines 67–70 and weekdayLabel at lines 220–222). With es_ES, this produces a localized month beside English MON/TUE headings, contrary to the PR's claim that the calendar's weekday/month names respect the system locale. Keep the English locale for the prose tooltip if needed, but format the grid headings with Qt.locale() and locale-aware casing.
                text: root.today.toLocaleDateString(Qt.locale(), "MMMM d")

Comment thread test/shell.d/clock-test.sh Resolved
labelLocale was hardcoded to Qt.locale("en_US"), so the calendar grid's
weekday headers (SUN/MON/TUE...) stayed English even after the month and
hero date were made locale-aware, contradicting the PR's premise. Made
labelLocale follow the system locale, switched weekdayLabel's casing to
toLocaleUpperCase() for the same reason as the month label, and added
wiring assertions for both the month label and the weekday headers so
neither can silently regress.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@ivanlegranbizarro

Copy link
Copy Markdown
Author

Closing this — while digging into locale handling more broadly I found #6988 (merged 9 days ago), which deliberately reverted this exact kind of localization: Qt.formatDate/Qt.formatDateTime render dddd/MMMM from the C locale on purpose, keeping the bar clock and calendar's weekday/month names in English to match the rest of the shell, which is English throughout.

As stated there: "a real system-wide translation is a separate future project" — not something to patch in widget by widget. There's an open feature request for that (#7284) and a couple of in-progress attempts at a full i18n system (#7955, #7434), which is the right place for this kind of change to land.

Given that, going forward with this PR (or expanding it into a broader translation fix) would just work against a very recent, explicit maintainer decision. Closing rather than pushing more changes against that grain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants